function dN = reference_basis_points_2d(basis_type, derivative_type)

switch basis_type
    case "P1"
        dN = cell(3,1);
        if (nargin == 1)||(derivative_type == "x")
            dN{1} = [0.78729833462074172434341789994505, 0.44364916731037085106947870372096, 0.1, 0.44364916731037085106947870372096, 0.25, 0.056350832689629148930521296279039, 0.1, 0.056350832689629148930521296279039, 0.012701665379258306187715277246753];
            dN{2} = [0.11270166537925829786104259255808, 0.11270166537925829786104259255808, 0.11270166537925829786104259255808, 0.5, 0.5, 0.5, 0.88729833462074170213895740744192, 0.88729833462074170213895740744192, 0.88729833462074170213895740744192];
            dN{3} = [0.1, 0.44364916731037085106947870372096, 0.78729833462074172434341789994505, 0.056350832689629148930521296279039, 0.25, 0.44364916731037085106947870372096, 0.01270166537925830792243875322356, 0.056350832689629148930521296279039, 0.1];
        elseif derivative_type == "dx"
            dN{1} = [-1, -1, -1, -1, -1, -1, -1, -1, -1];
            dN{2} = [1, 1, 1, 1, 1, 1, 1, 1, 1];
            dN{3} = [0, 0, 0, 0, 0, 0, 0, 0, 0];
        elseif derivative_type == "dy"
            dN{1} = [-1, -1, -1, -1, -1, -1, -1, -1, -1];
            dN{2} = [0, 0, 0, 0, 0, 0, 0, 0, 0];
            dN{3} = [1, 1, 1, 1, 1, 1, 1, 1, 1];
        end

    case "P1b"
        dN = cell(4,1);
        if (nargin == 1)||(derivative_type == "x")
            dN{1} = [0.78729833462074172434341789994505, 0.44364916731037085106947870372096, 0.1, 0.44364916731037085106947870372096, 0.25, 0.056350832689629148930521296279039, 0.1, 0.056350832689629148930521296279039, 0.012701665379258306187715277246753];
            dN{2} = [0.11270166537925829786104259255808, 0.11270166537925829786104259255808, 0.11270166537925829786104259255808, 0.5, 0.5, 0.5, 0.88729833462074170213895740744192, 0.88729833462074170213895740744192, 0.88729833462074170213895740744192];
            dN{3} = [0.1, 0.44364916731037085106947870372096, 0.78729833462074172434341789994505, 0.056350832689629148930521296279039, 0.25, 0.44364916731037085106947870372096, 0.01270166537925830792243875322356, 0.056350832689629148930521296279039, 0.1];
            dN{4} = [0.23957055034760019185391399787477, 0.59892637586900054902372403375921, 0.23957055034760016409833838224586, 0.3375, 0.84375, 0.3375, 0.030429449652399732234586693380152, 0.076073624130999342729531065288029, 0.030429449652399728765139741426538];
        elseif derivative_type == "dx"
            dN{1} = [-1, -1, -1, -1, -1, -1, -1, -1, -1];
            dN{2} = [1, 1, 1, 1, 1, 1, 1, 1, 1];
            dN{3} = [0, 0, 0, 0, 0, 0, 0, 0, 0];
            dN{4} = [1.82141100695200486292435471114, 3.9642637586900075774565266328864, -0.27, -0.085736241309993577175418977276422, -1.6875, -5.3142637586900054458283193525858, -0.27, -1.2642637586900062895978180677048, -2.3614110069520051204960964241764];
        elseif derivative_type == "dy"
            dN{1} = [-1, -1, -1, -1, -1, -1, -1, -1, -1];
            dN{2} = [0, 0, 0, 0, 0, 0, 0, 0, 0];
            dN{3} = [1, 1, 1, 1, 1, 1, 1, 1, 1];
            dN{4} = [2.0914110069520051179968033158825, 0.00000000000000022204460492503130808472633361816, -2.0914110069520051179968033158825, 5.2285275173800127949920082897062, 0, -5.2285275173800127949920082897062, 2.0914110069520051179968033158825, 0.00000000000000066613381477509392425417900085449, -2.0914110069520051179968033158825];
        end

    case "P2"
        dN = cell(6,1);
        if (nargin == 1)||(derivative_type == "x")
            dN{1} = [0.45237900077244508345586382347392, -0.05, -0.08, -0.05, -0.125, -0.05, -0.08, -0.05, -0.012379000772444970213115311707952];
            dN{4} = [0.35491933384829665865112247047364, 0.2, 0.045080666151703308042186790771666, 0.88729833462074170213895740744192, 0.5, 0.11270166537925829786104259255808, 0.35491933384829660313997123921581, 0.2, 0.045080666151703252531035559513839];
            dN{2} = [-0.087298334620741685485612038064573, -0.087298334620741685485612038064573, -0.087298334620741685485612038064573, 0, 0, 0, 0.68729833462074174654787839244818, 0.68729833462074174654787839244818, 0.68729833462074174654787839244818];
            dN{5} = [0.045080666151703314981080694678894, 0.2, 0.35491933384829665865112247047364, 0.11270166537925829786104259255808, 0.5, 0.88729833462074170213895740744192, 0.045080666151703314981080694678894, 0.2, 0.35491933384829665865112247047364];
            dN{3} = [-0.08, -0.05, 0.45237900077244519447816628598957, -0.05, -0.125, -0.05, -0.012379000772445010111755259174515, -0.05, -0.08];
            dN{6} = [0.31491933384829667863513691372646, 0.78729833462074172434341789994505, 0.31491933384829640107938075743732, 0.1, 0.25, 0.1, 0.0050806661517033210873073301172553, 0.012701665379258292309927469432296, 0.0050806661517033280262012340244837];
        elseif derivative_type == "dx"
            dN{1} = [-2.1491933384829668973736715997802, -0.77459666924148337703585307995648, 0.6, -0.77459666924148337703585307995648, 0, 0.77459666924148337703585307995648, 0.6, 0.77459666924148337703585307995648, 0.94919333848296671973798765975516];
            dN{4} = [2.6983866769659337059295012295479, 1.3237900077244502128337444446515, -0.050806661517032836172802490182221, -0.22540333075851659572208518511616, -1.0, -1.7745966692414834042779148148838, -3.1491933384829664532844617497176, -3.3237900077244502128337444446515, -3.4983866769659339723830271395855];
            dN{2} = [-0.54919333848296680855582962976769, -0.54919333848296680855582962976769, -0.54919333848296680855582962976769, 1.0, 1.0, 1.0, 2.5491933384829668085558296297677, 2.5491933384829668085558296297677, 2.5491933384829668085558296297677];
            dN{5} = [0.4, 1.7745966692414834042779148148838, 3.1491933384829668973736715997802, 0.22540333075851659572208518511616, 1.0, 1.7745966692414834042779148148838, 0.050806661517033231689755012894238, 0.22540333075851659572208518511616, 0.4];
            dN{3} = [0, 0, 0, 0, 0, 0, 0, 0, 0];
            dN{6} = [-0.4, -1.7745966692414834042779148148838, -3.1491933384829668973736715997802, -0.22540333075851659572208518511616, -1.0, -1.7745966692414834042779148148838, -0.050806661517033231689755012894238, -0.22540333075851659572208518511616, -0.4];
        elseif derivative_type == "dy"
            dN{1} = [-2.1491933384829668973736715997802, -0.77459666924148337703585307995648, 0.6, -0.77459666924148337703585307995648, 0, 0.77459666924148337703585307995648, 0.6, 0.77459666924148337703585307995648, 0.94919333848296671973798765975516];
            dN{4} = [-0.45080666151703319144417037023231, -0.45080666151703319144417037023231, -0.45080666151703319144417037023231, -2.0, -2.0, -2.0, -3.5491933384829668085558296297677, -3.5491933384829668085558296297677, -3.5491933384829668085558296297677];
            dN{2} = [0, 0, 0, 0, 0, 0, 0, 0, 0];
            dN{5} = [0.45080666151703319144417037023231, 0.45080666151703319144417037023231, 0.45080666151703319144417037023231, 2.0, 2.0, 2.0, 3.5491933384829668085558296297677, 3.5491933384829668085558296297677, 3.5491933384829668085558296297677];
            dN{3} = [-0.6, 0.77459666924148337703585307995648, 2.1491933384829668973736715997802, -0.77459666924148337703585307995648, 0, 0.77459666924148337703585307995648, -0.94919333848296671973798765975516, -0.77459666924148337703585307995648, -0.6];
            dN{6} = [2.7491933384829669861915135697927, 0, -2.7491933384829669861915135697927, 1.549193338482966754071706159913, 0, -1.549193338482966754071706159913, 0.34919333848296663092014568974264, 0, -0.34919333848296663092014568974264];
        end

    case "Q1"
        dN = cell(4,1);
        if (nargin == 1)||(derivative_type == "x")
            dN{1} = [0.78729833462074172434341789994505, 0.44364916731037085106947870372096, 0.1, 0.44364916731037085106947870372096, 0.25, 0.056350832689629148930521296279039, 0.1, 0.056350832689629148930521296279039, 0.012701665379258320065503085061209];
            dN{2} = [0.1, 0.056350832689629148930521296279039, 0.012701665379258320065503085061209, 0.44364916731037085106947870372096, 0.25, 0.056350832689629148930521296279039, 0.78729833462074172434341789994505, 0.44364916731037085106947870372096, 0.1];
            dN{3} = [0.012701665379258320065503085061209, 0.056350832689629148930521296279039, 0.1, 0.056350832689629148930521296279039, 0.25, 0.44364916731037085106947870372096, 0.1, 0.44364916731037085106947870372096, 0.78729833462074172434341789994505];
            dN{4} = [0.1, 0.44364916731037085106947870372096, 0.78729833462074172434341789994505, 0.056350832689629148930521296279039, 0.25, 0.44364916731037085106947870372096, 0.012701665379258320065503085061209, 0.056350832689629148930521296279039, 0.1];
        elseif derivative_type == "dx"
            dN{1} = [-0.44364916731037085106947870372096, -0.25, -0.056350832689629148930521296279039, -0.44364916731037085106947870372096, -0.25, -0.056350832689629148930521296279039, -0.44364916731037085106947870372096, -0.25, -0.056350832689629148930521296279039];
            dN{2} = [0.44364916731037085106947870372096, 0.25, 0.056350832689629148930521296279039, 0.44364916731037085106947870372096, 0.25, 0.056350832689629148930521296279039, 0.44364916731037085106947870372096, 0.25, 0.056350832689629148930521296279039];
            dN{3} = [0.056350832689629148930521296279039, 0.25, 0.44364916731037085106947870372096, 0.056350832689629148930521296279039, 0.25, 0.44364916731037085106947870372096, 0.056350832689629148930521296279039, 0.25, 0.44364916731037085106947870372096];
            dN{4} = [-0.056350832689629148930521296279039, -0.25, -0.44364916731037085106947870372096, -0.056350832689629148930521296279039, -0.25, -0.44364916731037085106947870372096, -0.056350832689629148930521296279039, -0.25, -0.44364916731037085106947870372096];
        elseif derivative_type == "dy"
            dN{1} = [-0.44364916731037085106947870372096, -0.44364916731037085106947870372096, -0.44364916731037085106947870372096, -0.25, -0.25, -0.25, -0.056350832689629148930521296279039, -0.056350832689629148930521296279039, -0.056350832689629148930521296279039];
            dN{2} = [-0.056350832689629148930521296279039, -0.056350832689629148930521296279039, -0.056350832689629148930521296279039, -0.25, -0.25, -0.25, -0.44364916731037085106947870372096, -0.44364916731037085106947870372096, -0.44364916731037085106947870372096];
            dN{3} = [0.056350832689629148930521296279039, 0.056350832689629148930521296279039, 0.056350832689629148930521296279039, 0.25, 0.25, 0.25, 0.44364916731037085106947870372096, 0.44364916731037085106947870372096, 0.44364916731037085106947870372096];
            dN{4} = [0.44364916731037085106947870372096, 0.44364916731037085106947870372096, 0.44364916731037085106947870372096, 0.25, 0.25, 0.25, 0.056350832689629148930521296279039, 0.056350832689629148930521296279039, 0.056350832689629148930521296279039];
        end

    case "Q1b"
        dN = cell(5,1);
        if (nargin == 1)||(derivative_type == "x")
            dN{1} = [0.78729833462074172434341789994505, 0.44364916731037085106947870372096, 0.1, 0.44364916731037085106947870372096, 0.25, 0.056350832689629148930521296279039, 0.1, 0.056350832689629148930521296279039, 0.012701665379258320065503085061209];
            dN{2} = [0.1, 0.056350832689629148930521296279039, 0.012701665379258320065503085061209, 0.44364916731037085106947870372096, 0.25, 0.056350832689629148930521296279039, 0.78729833462074172434341789994505, 0.44364916731037085106947870372096, 0.1];
            dN{3} = [0.012701665379258320065503085061209, 0.056350832689629148930521296279039, 0.1, 0.056350832689629148930521296279039, 0.25, 0.44364916731037085106947870372096, 0.1, 0.44364916731037085106947870372096, 0.78729833462074172434341789994505];
            dN{4} = [0.1, 0.44364916731037085106947870372096, 0.78729833462074172434341789994505, 0.056350832689629148930521296279039, 0.25, 0.44364916731037085106947870372096, 0.012701665379258320065503085061209, 0.056350832689629148930521296279039, 0.1];
            dN{5} = [0.0256, 0.16, 0.0256, 0.16, 1.0, 0.16, 0.0256, 0.16, 0.0256];
        elseif derivative_type == "dx"
            dN{1} = [-0.44364916731037085106947870372096, -0.25, -0.056350832689629148930521296279039, -0.44364916731037085106947870372096, -0.25, -0.056350832689629148930521296279039, -0.44364916731037085106947870372096, -0.25, -0.056350832689629148930521296279039];
            dN{2} = [0.44364916731037085106947870372096, 0.25, 0.056350832689629148930521296279039, 0.44364916731037085106947870372096, 0.25, 0.056350832689629148930521296279039, 0.44364916731037085106947870372096, 0.25, 0.056350832689629148930521296279039];
            dN{3} = [0.056350832689629148930521296279039, 0.25, 0.44364916731037085106947870372096, 0.056350832689629148930521296279039, 0.25, 0.44364916731037085106947870372096, 0.056350832689629148930521296279039, 0.25, 0.44364916731037085106947870372096];
            dN{4} = [-0.056350832689629148930521296279039, -0.25, -0.44364916731037085106947870372096, -0.056350832689629148930521296279039, -0.25, -0.44364916731037085106947870372096, -0.056350832689629148930521296279039, -0.25, -0.44364916731037085106947870372096];
            dN{5} = [0.19829674732581974452117838846886, 1.2393546707863734032573649279304, 0.19829674732581974452117838846886, 0, 0, 0, -0.19829674732581974452117838846886, -1.2393546707863734032573649279304, -0.19829674732581974452117838846886];
        elseif derivative_type == "dy"
            dN{1} = [-0.44364916731037085106947870372096, -0.44364916731037085106947870372096, -0.44364916731037085106947870372096, -0.25, -0.25, -0.25, -0.056350832689629148930521296279039, -0.056350832689629148930521296279039, -0.056350832689629148930521296279039];
            dN{2} = [-0.056350832689629148930521296279039, -0.056350832689629148930521296279039, -0.056350832689629148930521296279039, -0.25, -0.25, -0.25, -0.44364916731037085106947870372096, -0.44364916731037085106947870372096, -0.44364916731037085106947870372096];
            dN{3} = [0.056350832689629148930521296279039, 0.056350832689629148930521296279039, 0.056350832689629148930521296279039, 0.25, 0.25, 0.25, 0.44364916731037085106947870372096, 0.44364916731037085106947870372096, 0.44364916731037085106947870372096];
            dN{4} = [0.44364916731037085106947870372096, 0.44364916731037085106947870372096, 0.44364916731037085106947870372096, 0.25, 0.25, 0.25, 0.056350832689629148930521296279039, 0.056350832689629148930521296279039, 0.056350832689629148930521296279039];
            dN{5} = [0.19829674732581974452117838846886, 0, -0.19829674732581974452117838846886, 1.2393546707863734032573649279304, 0, -1.2393546707863734032573649279304, 0.19829674732581974452117838846886, 0, -0.19829674732581974452117838846886];
        end

    case "Q2"
        dN = cell(9,1);
        if (nargin == 1)||(derivative_type == "x")
            dN{1} = [0.47237900077244515673058344873425, 0, -0.06, 0, 0, 0, -0.06, 0, 0.0076209992275549920393018510367256];
            dN{5} = [0.27491933384829664310800012572145, 0, -0.034919333848296651989784322722699, 0.68729833462074174654787839244818, 0, -0.08729833462074165773003642243566, 0.27491933384829664310800012572145, 0, -0.034919333848296651989784322722699];
            dN{2} = [-0.06, 0, 0.0076209992275549920393018510367256, 0, 0, 0, 0.47237900077244515673058344873425, 0, -0.06];
            dN{6} = [-0.034919333848296651989784322722699, -0.08729833462074165773003642243566, -0.034919333848296651989784322722699, 0, 0, 0, 0.27491933384829664310800012572145, 0.68729833462074174654787839244818, 0.27491933384829664310800012572145];
            dN{3} = [0.0076209992275549920393018510367256, 0, -0.06, 0, 0, 0, -0.06, 0, 0.47237900077244515673058344873425];
            dN{7} = [-0.034919333848296651989784322722699, 0, 0.27491933384829664310800012572145, -0.08729833462074165773003642243566, 0, 0.68729833462074174654787839244818, -0.034919333848296651989784322722699, 0, 0.27491933384829664310800012572145];
            dN{4} = [-0.06, 0, 0.47237900077244515673058344873425, 0, 0, 0, 0.0076209992275549920393018510367256, 0, -0.06];
            dN{8} = [0.27491933384829664310800012572145, 0.68729833462074174654787839244818, 0.27491933384829664310800012572145, 0, 0, 0, -0.034919333848296651989784322722699, -0.08729833462074165773003642243566, -0.034919333848296651989784322722699];
            dN{9} = [0.16, 0.4, 0.16, 0.4, 1.0, 0.4, 0.16, 0.4, 0.16];
        elseif derivative_type == "dx"
            dN{1} = [-0.87602816808281602778407659570803, 0, 0.11127016653792581868387401300424, -0.34364916731037087327393919622409, 0, 0.04364916731037082886501821121783, 0.18872983346207422572504697200202, 0, -0.023971831917184160953837590568583];
            dN{5} = [1.0647580015448903090202747989679, 0, -0.13524199845510997963771160357282, 0, 0, 0, -1.0647580015448903090202747989679, 0, 0.13524199845510997963771160357282];
            dN{2} = [-0.18872983346207422572504697200202, 0, 0.023971831917184160953837590568583, 0.34364916731037087327393919622409, 0, -0.04364916731037082886501821121783, 0.87602816808281602778407659570803, 0, -0.11127016653792581868387401300424];
            dN{6} = [-0.10983866769659333950670543345041, -0.27459666924148340427791481488384, -0.10983866769659333950670543345041, 0.2, 0.5, 0.2, 0.50983866769659325068886346343788, 1.2745966692414834042779148148838, 0.50983866769659325068886346343788];
            dN{3} = [0.023971831917184160953837590568583, 0, -0.18872983346207422572504697200202, -0.04364916731037082886501821121783, 0, 0.34364916731037087327393919622409, -0.11127016653792581868387401300424, 0, 0.87602816808281602778407659570803];
            dN{7} = [-0.13524199845510997963771160357282, 0, 1.0647580015448903090202747989679, 0, 0, 0, 0.13524199845510997963771160357282, 0, -1.0647580015448903090202747989679];
            dN{4} = [0.11127016653792581868387401300424, 0, -0.87602816808281602778407659570803, 0.04364916731037082886501821121783, 0, -0.34364916731037087327393919622409, -0.023971831917184160953837590568583, 0, 0.18872983346207422572504697200202];
            dN{8} = [-0.50983866769659325068886346343788, -1.2745966692414834042779148148838, -0.50983866769659325068886346343788, -0.2, -0.5, -0.2, 0.10983866769659333950670543345041, 0.27459666924148340427791481488384, 0.10983866769659333950670543345041];
            dN{9} = [0.61967733539318670162868246396518, 1.549193338482966754071706159913, 0.61967733539318670162868246396518, 0, 0, 0, -0.61967733539318670162868246396518, -1.549193338482966754071706159913, -0.61967733539318670162868246396518];
        elseif derivative_type == "dy"
            dN{1} = [-0.87602816808281602778407659570803, -0.34364916731037087327393919622409, 0.18872983346207422572504697200202, 0, 0, 0, 0.11127016653792581868387401300424, 0.04364916731037082886501821121783, -0.023971831917184160953837590568583];
            dN{5} = [-0.50983866769659325068886346343788, -0.2, 0.10983866769659333950670543345041, -1.2745966692414834042779148148838, -0.5, 0.27459666924148340427791481488384, -0.50983866769659325068886346343788, -0.2, 0.10983866769659333950670543345041];
            dN{2} = [0.11127016653792581868387401300424, 0.04364916731037082886501821121783, -0.023971831917184160953837590568583, 0, 0, 0, -0.87602816808281602778407659570803, -0.34364916731037087327393919622409, 0.18872983346207422572504697200202];
            dN{6} = [-0.13524199845510997963771160357282, 0, 0.13524199845510997963771160357282, 0, 0, 0, 1.0647580015448903090202747989679, 0, -1.0647580015448903090202747989679];
            dN{3} = [0.023971831917184160953837590568583, -0.04364916731037082886501821121783, -0.11127016653792581868387401300424, 0, 0, 0, -0.18872983346207422572504697200202, 0.34364916731037087327393919622409, 0.87602816808281602778407659570803];
            dN{7} = [-0.10983866769659333950670543345041, 0.2, 0.50983866769659325068886346343788, -0.27459666924148340427791481488384, 0.5, 1.2745966692414834042779148148838, -0.10983866769659333950670543345041, 0.2, 0.50983866769659325068886346343788];
            dN{4} = [-0.18872983346207422572504697200202, 0.34364916731037087327393919622409, 0.87602816808281602778407659570803, 0, 0, 0, 0.023971831917184160953837590568583, -0.04364916731037082886501821121783, -0.11127016653792581868387401300424];
            dN{8} = [1.0647580015448903090202747989679, 0, -1.0647580015448903090202747989679, 0, 0, 0, -0.13524199845510997963771160357282, 0, 0.13524199845510997963771160357282];
            dN{9} = [0.61967733539318670162868246396518, 0, -0.61967733539318670162868246396518, 1.549193338482966754071706159913, 0, -1.549193338482966754071706159913, 0.61967733539318670162868246396518, 0, -0.61967733539318670162868246396518];
        end

    otherwise
        error("Invalid basis type.");
end

end